package com.zh.note.leetcode.dp;

import java.util.Arrays;

/**
 * 674. 最长连续递增序列
 */
public class LC_674_findLengthOfLCIS {

    public int findLengthOfLCIS(int[] nums) {
        if (nums.length <= 1) {
            return nums.length;
        }

        //dp[i]：以下标i为结尾的连续递增的子序列长度为dp[i]
        int[] dp = new int[nums.length];
        Arrays.fill(dp, 1);
        int res = 0;
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] > nums[i - 1]) {
                dp[i] = dp[i - 1] + 1;
            }
            if (dp[i] > res) {
                res = dp[i];
            }
        }
        return res;
    }
}
